/*
    Copyright j&g dev team(c). All Rights Reserved
    Notice: NONE
*/

#ifndef ENTITY_H
#define ENTITY_H

#include "interfaces.h"
#include <string>

namespace GoldenAges
{
    class CEntity : public IBaseEntity
    {
    private:
        int m_iPosX;
        int m_iPosY;

        SDL_Surface *m_pSurface;
        bool m_bIsVisible;
        int m_iAlphaChannel;

        std::string m_sImageFileName;

        int m_iTilePosX;
        int m_iTilePosY;

        void SetPosX(int iPosX)                 { m_iPosX = iPosX; }
        void SetPosY(int iPosY)                 { m_iPosY = iPosY; }
        void SetPos(int iPosX, int iPosY)       { m_iPosX = iPosX; m_iPosY = iPosY; }
    protected:
        virtual bool LoadImageFromFile(const std::string &sFileName);

        int GetPosX(void)                       { return m_iPosX; }
        int GetPosY(void)                       { return m_iPosY; }

        void SetAlphaChannel(int iAlphaChannel) { m_iAlphaChannel = iAlphaChannel; }
        void SetVisible(bool bVisible)          { m_bIsVisible = bVisible; }

        SDL_Rect GetEntityRect(void);
    public:
        CEntity(void);
        virtual ~CEntity(void);

        virtual void Think(const int &iElapsedTime);
        virtual void Render(SDL_Surface *pDestSurf);
        virtual TiXmlElement SaveData(void);
        virtual bool LoadData(TiXmlElement* pXMLData);

        void SetTilePosX(int iPosX)             { m_iTilePosX = iPosX; }
        void SetTilePosY(int iPosY)             { m_iTilePosY = iPosY; }
        void SetTilePos(int iPosX, int iPosY)   { m_iTilePosX = iPosX; m_iTilePosY = iPosY; }

        int GetTilePosX(void)                   { return m_iTilePosX; }
        int GetTilePosY(void)                   { return m_iTilePosY; }

        int GetHeight(void)                     { return m_pSurface->h; } // wysokosc
        int GetWidth(void)                      { return m_pSurface->w; } // szerokosc

        int GetBottom(void)                     { return m_iPosY + m_pSurface->h; }
        int GetRight(void)                      { return m_iPosX + m_pSurface->w; }

        int GetAlphaChannel(void)               { return m_iAlphaChannel; }
        bool IsVisible(void)                    { return m_bIsVisible; }
    };
}

#endif // ENTITY_H

